<?php
/**
 * @Author: anchen
 * @Date:   2017-11-02 11:34:21
 * @Last Modified by:   anchen
 * @Last Modified time: 2017-12-20 16:56:52
 */
define('IN_QY', true);
session_start();
require("include/common.inc.php");
require('include/functions.php');
require('sku_model.php');

$now_url = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
setcookie("last_url",$now_url,time()+(3600));

$id = trim($_GET['id']);
$sql = "select * from tbl_taospp where id = " . $id;
$query = mysql_query($sql);
$row = mysql_fetch_array($query);
$temp = $row['img'];
$arr = explode(",", $temp);
$temp = $row['agentprice'];
$arr1 = explode(",", $temp);

$hotlevel = isset($row['hotlevel']) ? $row['hotlevel'] : 0; // 大拇指
$ggunit = $row['ggunit']; // 自营图片

// sku调用
$goods_id = $id;
$goods_sku_arr = get_goods_sku_arr($goods_id);
$choosed_sku = '';
$sku_id = '';
if($_GET['sku_id']){
    $sku_id = $_GET['sku_id'];
    $choosed_sku = c_getRow("select * from tbl_goods_sku WHERE id = ".$_GET['sku_id']." limit 1");
    $sku_info_name = explode(',',$choosed_sku['sku_info_name']);
    $choosed_sku['sku_info_name_arr'] = $sku_info_name;
    $sku_pic_arr = $choosed_sku['sku_pic'] ? explode(',',$choosed_sku['sku_pic']) : '';
}
list($get_goods_sku_show_list,$sku_info_key_ch_arr) = get_goods_sku_show_list($goods_id);
?>

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">

    <title>商品页面</title>

    <link href="fetch/AmazeUI-2.4.2/assets/css/admin.css" rel="stylesheet" type="text/css"/>
    <link href="fetch/AmazeUI-2.4.2/assets/css/amazeui.css" rel="stylesheet" type="text/css"/>
    <link href="fetch/basic/css/demo.css" rel="stylesheet" type="text/css"/>
    <link type="text/css" href="fetch/css/optstyle.css" rel="stylesheet"/>
    <link type="text/css" href="fetch/css/style.css" rel="stylesheet"/>
    <link type="text/css" href="/ui/layui/css/layui.css" rel="stylesheet"/>
    <link rel="stylesheet" type="text/css" href="/sy/csxz/css/hzw-city-picker.css">
    <script type="text/javascript" src="/sy/csxz/js/city-data.js"></script>
    <script type="text/javascript" src="/sy/csxz/js/hzw-city-picker.min.js"></script>
    <script src="/ui/two/AmazeUI-2.4.2/assets/js/jquery.min.js"></script>
    <script src="/ui/two/AmazeUI-2.4.2/assets/js/amazeui.min.js"></script>
    <script type="text/javascript" src="fetch/js/address.js"></script>
    <script src="/ui/layer/layer.js"></script>
    <script src="/ui/layui/layui.all.js"></script>
    <style type="text/css">
        #searchnav {
            height: 20px;
            text-align: center;
            margin-left: 18px;
        }

        #searchnav p {
            height: 100%;
            width: 48px;
            margin-right: 6px;
            border-radius: 10px 10px 0 0;
            float: left;
            cursor: pointer;
            color: #fff;
            background: linear-gradient(#f86b54, #dc4835);
        }

        .left {
            float: left;
            margin-right: 20px;
        }

        .left img {
            border-radius: 5px;
        }

        .right {
            float: left;
        }

        .name {
            height: 20px;
            margin-bottom: 20px;
        }

        .name .name1 {
            line-height: 20px;
            font-size: 18px;
            margin-right: 10px;
        }

        .loft {
            height: 20px;
            margin-bottom: 20px;
        }

        .loft .q1 {
            font-size: 18px;
            line-height: 20px;
        }

        .loft .q2 {
            font-size: 18px;
            line-height: 20px;
            color: #FF5719;
        }

        .loft .q3 {
            font-size: 14px;
            line-height: 20px;
        }

        .layui-form-item {
            display: inline-block;
        }
    </style>
</head>

<body>

<!--顶部导航条 -->
<? include('head1.php'); ?>

<div class="clear"></div>

<div class="listMain">
    <!--分类-->

    <ol class="am-breadcrumb am-breadcrumb-slash">
        <li><a href="#">
                <?php
                $sql = "select spe_val from tbl_specifa where id=" . $row['typeid'];
                $query = mysql_query($sql);
                $rowf1 = mysql_fetch_array($query);
                echo $rowf1['spe_val'];
                ?>
            </a></li>
        <li><a href="#">
                <?php
                $sql = "select spe_val from tbl_specifa where id=" . $row['entitle'];
                $query = mysql_query($sql);
                $rowf2 = mysql_fetch_array($query);
                echo $rowf2['spe_val'];
                ?>
            </a></li>
    </ol>

    <!--放大镜-->

    <div class="item-inform">
        <div class="clearfixLeft" id="clearcontent">

            <div class="box" >

                <!-- <div class="tb-booth tb-pic tb-s310">


							</div> -->
                <div id="lunbotu" class="am-slider am-slider-default" data-am-flexslider style="width: 400px;height: 400px">
                    <ul class="am-slides">
                        <?
                            if(!empty($sku_pic_arr)){
                                $arr = $sku_pic_arr;
                            }
                        ?>

                        <?php foreach ($arr as $v) { ?>
                            <li><img src="<?php echo $v; ?>" height="400" width="400"/></li>
                        <?php } ?>
                    </ul>
                </div>
            </div>

            <div class="clear"></div>
        </div>

        <div class="clearfixRight">

            <!--规格属性-->
            <!--名称-->
            <div class="tb-detail-hd">
                <h1>
                    <?php echo $row['chtitle']; ?>
                </h1>
                <span>
                      <?php if($row['linkurl'] == 1){
                          $goods_id = $row['id'];
                          $pc_url = c_getRow("select * from tbl_goods_link WHERE goods_id = '$goods_id' limit 1; ")['pc'];
                          if($pc_url){
                              echo "<img style='height: 18px;width: 18px' src='images/hui.png'>&nbsp;&nbsp;<a style='color: #E4393C' href='$pc_url'>点我前往套餐，享受更多优惠！</a>";
                          }

                      } ?>
                </span>
            </div>
            <div class="tb-detail-list">
                <!--价格-->
                <div class="tb-detail-price" style="height: 40px">
                    <li class="price iteminfo_price">
                        <dt>售价</dt>
                        <dd><em>¥</em><b class="sys_item_price">
                                <?php if($choosed_sku){
                                    // 显示sku价格
                                    echo number_format($choosed_sku['price'],2);
                                }else{
                                    echo number_format($row['zswprice'],2);
                                }
                                ?>
                            </b></dd>
                        <!-- 大拇指 cj -->
                        <span style="float: right;margin-right: 22px">
                                        <?php if ($hotlevel != 0) {
                                            for ($i = 0; $i < $hotlevel; $i++) {
                                                echo "<img src='./images/hotlevel.png' style='width: 30px;height: 30px;'>";
                                            }
                                        }
                                        ?>
                                    </span>
                        <span style="float: right;margin-right: 22px">
                                        <?php if ($ggunit == 0) {
                                            echo "<img src='./images/ggunit.png' style='width: 100px;height: 30px;'>";
                                        }
                                        ?>
                                    </span>
                    </li>

                    <div class="clear"></div>
                </div>
                <br><br>

                <!--地址-->
                <?php if ($row['entitle'] == 9) { ?>
                    <p>运费：包邮</p>
                <?php }
                ?>
                <div style="height: 120px;width: 700px;text-align: left;">
                    <p>优惠券获取：在众晒网消费即可获赠2元、3元、10元券各一张，单笔订单满100元再赠送20元、25元券各一张</p>
                    <p style="float: left;">优惠券抵扣：</p>
                    <?if ($ggunit == 0) { ?>
                    <ul style="float: left;margin-top: 5px">
                        <li><img src="/vip/images/taomini.png" width="108" height="24" style="margin-bottom: 5px">饼干单笔订单满59元可抵扣2元优惠券
                        </li>
                        <li><img src="/vip/images/taomini.png" width="108" height="24" style="margin-bottom: 5px">儿童牙膏单笔订单满39元可抵扣2元优惠券
                        </li>
                        <li><img src="/vip/images/taomini.png" width="108" height="24">洗洁精单笔订单满59元可抵扣2元优惠券</li>
                    </ul>
                    <? } else { ?>
                    <ul style="float: left;margin-top: 5px">
                        <li style="line-height:1.7"><p style="margin-top:10px;margin-left:10px;"><img style="height: 20px;width: 60px;" src="./images/hotlevel3.png">类产品，单笔订单满299元可抵扣25元优惠券；单笔订单满199元可抵扣10元优惠券；</p></li>
                        <li style="line-height:1.7"><p style="margin-left:10px;"><img style="height: 20px;width: 40px;" src="./images/hotlevel2.png">类产品，单笔订单满189元可抵扣20元优惠券；</p></li>
                        <li style="line-height:1.7"><p style="margin-left:10px;"><img style="height: 20px;width: 20px;" src="./images/hotlevel.png">类产品，单笔订单满89元可抵扣3元优惠券；单笔订单满65元可抵扣2元优惠券；</p></li>
                    </ul>
                    <? } ?>
                    <p style="clear: left;color: #5ADBF9;margin-left: 400px" id="morecc">更多</p>
                </div>

                <!-- sku选择 -->
                <?
                    if($goods_sku_arr){
                        include('sku_choose.php');
                    }
                ?>

                <!-- 购物车 -->
                <div class="tb-detail-price" style="height: 40px;margin-top: 10px">
                    <input type="hidden" id="tgid" value="<?php echo $id; ?>">
                    <input type="hidden" id="skuid" value="<?=$sku_id?>">
                    <li class="price iteminfo_price" style="float: left;">
                        <span>购买数量：</span>
                        <input class="min am-btn" name="" type="button" value="-"/>
                        <input class="text_box" id="goodsnum" name="goodsnum" readonly="readonly" type="text"
                               style="width:30px;" value="1"/>
                        <input class="add am-btn" name="" type="button" value="+"/>
                    </li>

                    <div class="clear"></div>
                </div>

                <div class="clear"></div>
                <!--活动	-->
            </div>
            <br>
            <div class="pay">
                <div class="pay-opt">

                </div>
                <li style="margin-top: 0">
                    <div class="clearfix tb-btn tb-btn-buy theme-login" style="margin-left: 0">
                        <a id="LikBuy" title="点此按钮到下一步确认购买信息" onclick="goto_buy()">立即购买</a>
                    </div>
                </li>
                <li style="margin-top: 0;width: 100px;border: 1px solid red;background-color: #FFEDED;text-align: center;">
                    <span id="LikBasket" style="width: 98px;height: 26px">加入购物车</span>
                </li>

            </div>
            <br>
            <br><br><br>
            <div class="tb-detail-hd">
                <ul class="tm-ind-panel">
                    <li class="tm-ind-item tm-ind-sellCount canClick" id="cc1">
                        <div class="tm-indcon"><span class="tm-label">联系卖家</span><span class="tm-count"></span></div>
                    </li>
                    <li class="tm-ind-item tm-ind-sellCount canClick" id="cc2">
                        <div class="tm-indcon" id="contseller"><span class="tm-label">服务说明</span><span
                                    class="tm-count"></span></div>
                    </li>
                </ul>
            </div>

        </div>

        <div class="clear"></div>

    </div>


    <!-- introduce-->

    <div class="introduce">
        <div class="introduceMain" style="width:90%;margin-left:5%;">
            <div class="am-tabs" data-am-tabs>
                <ul class="am-avg-sm-3 am-tabs-nav am-nav am-nav-tabs">
                    <li class="am-active">
                        <a href="#">

                            <span class="index-needs-dt-txt">宝贝详情</span></a>

                    </li>

                    <!-- <li id="panel1">
                        <a href="#">

                            <span class="index-needs-dt-txt">全部评价</span></a>

                    </li> -->

                    <li>
                        <a href="#">

                            <span class="index-needs-dt-txt">猜你喜欢</span></a>
                    </li>
                </ul>

                <div class="am-tabs-bd">
                    <img src="/vip/images/taosub.png" width="960" height="180" style="margin-left:
								-114px">
                    <div class="am-tab-panel am-fade am-in am-active">
                        <div class="J_Brand">

                            <div class="attr-list-hd tm-clear">
                                <h4>规格参数：</h4></div>
                            <div class="clear"></div>
                            <ul id="J_AttrUL">
                                <li title="" style="width:100%;">规格：<?php echo $row['ggid']; ?>
                                </li>
                                <li title="" style="width:100%;">箱规数量：<?php echo $row['ggnum']; ?>
                                </li>
                                <li title="" style="width:100%;">单位：<?php echo $row['unit']; ?>
                                </li>
                                <li title="" style="width:100%;">产地：<?php echo $row['origin']; ?>
                                </li>
                            </ul>
                            <div class="clear"></div>
                        </div>

                        <div class="J_Brand">

                            <div class="attr-list-hd tm-clear">
                                <h4>商品描述：</h4></div>
                            <div class="clear"></div>
                            <ul id="J_AttrUL">
                                <li title="" style="width:100%;"><?php echo $row['enbrand']; ?>
                                </li>
                            </ul>
                            <div class="clear"></div>
                        </div>


                        <div class="details">
                            <div class="attr-list-hd after-market-hd">
                                <h4>商品细节：</h4>
                            </div>
                            <div class="twlistNews">

                                <?php foreach ($arr1 as $v) {
                                    if (strlen($v) <= 0) {
                                        continue;
                                    }
                                    ?>
                                    <img src="<?php echo $v; ?>" style="width:50%"/>
                                <?php } ?>
                            </div>
                        </div>

                        <!--清关----->
                        <?php if($row['ggunit']!=0){ ?>
                            <div class="H-line-height-0">
                                <img src="./images/海购须知.jpg" style="width: 50%" class="H-width-100-percent ">
                                <img src="./images/清关图片.jpg" style="width: 50%"  class="H-width-100-percent ">
                            </div>
                        <?php } ?>

                        <div class="clear"></div>

                        <!--用户留言-->


                        <div class="details">
                            <?php
                            $sqlp = "select t1.article,t1.addtime,t2.username,t2.shuyu from tbl_article t1 inner join tbl_user t2 on t1.username=t2.id where t1.fid=" . $id;
                            $queryp = mysql_query($sqlp);
                            $rownums = mysql_num_rows($queryp);
                            if ($rownums > 0) {
                                ?>
                                <div class="attr-list-hd tm-clear">
                                    <h4>用户留言</h4>
                                </div>
                                <ul class="am-comments-list am-comments-list-flip">
                                    <?php

                                    while ($rowp = mysql_fetch_array($queryp)) { ?>

                                        <li class="am-comment">
                                            <!-- 评论容器 -->
                                            <a href="">
                                                <img class="am-comment-avatar" src="<?php echo $rowp['username']; ?>"/>
                                                <!-- 评论者头像 -->
                                            </a>

                                            <div class="am-comment-main">
                                                <!-- 评论内容容器 -->
                                                <header class="am-comment-hd">
                                                    <!--<h3 class="am-comment-title">评论标题</h3>-->
                                                    <div class="am-comment-meta">
                                                        <!-- 评论元数据 -->
                                                        <a href="#link-to-user"
                                                           class="am-comment-author"><?php echo $rowp['shuyu']; ?></a>
                                                        <!-- 评论者 -->
                                                        评论于
                                                        <time datetime=""><?php echo $rowp['addtime']; ?></time>
                                                        <span class="taoreyan" cc="<?php echo $rowp['shuyu']; ?>"
                                                              style="color: red;cursor: pointer;">回复</span>
                                                    </div>
                                                </header>

                                                <div class="am-comment-bd">
                                                    <div class="tb-rev-item " data-id="255776406962">
                                                        <div class="J_TbcRate_ReviewContent tb-tbcr-content ">
                                                            <?php echo $rowp['article']; ?>
                                                        </div>
                                                    </div>

                                                </div>
                                                <!-- 评论内容 -->
                                            </div>
                                        </li>
                                    <?php } ?>
                                </ul>
                            <?php } ?>
                        </div>
                        <div class="J_Brand" id="last">

                            <div class="attr-list-hd tm-clear">
                                <h4>发表评价：</h4></div>
                            <div class="clear"></div>
                            <form class="layui-form" method="post" action="taoyanfabu.php?fid=<?php echo $id; ?>"
                                  style="margin-top: 40px">
										  <textarea class="layui-textarea fly-editor" id="LAY_demo1" name="title">  
											  
											</textarea>
                                <div class="layui-form-item" style="margin-top: 10px">
                                    <div class="layui-input-inline">
                                        <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
                                    </div>
                                </div>
                            </form>


                        </div>
                        <!--分页 -->
                    </div>


                    <div class="am-tab-panel am-fade">
                        <div class="like">
                            <ul class="am-avg-sm-2 am-avg-md-3 am-avg-lg-4 boxes">
                                <?php
                                $sqll = "select * from tbl_taospp where state=0 order by id desc limit 12";
                                $queryl = mysql_query($sqll);
                                while ($rowl = mysql_fetch_array($queryl)) {
                                    $temp = $rowl['img'];
                                    $arr = explode(",", $temp);

                                    ?>
                                    <li><a href="taogoodetail.php?id=<?= $rowl['id'] ?>" target="_blank">
                                            <div class="i-pic limit">
                                                <img src="<?php echo $arr[0]; ?>"/>
                                                <p style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis;"><?php echo $rowl['chtitle']; ?>
                                                    <span><?php echo $tempcates; ?></span></p>
                                                <p class="price fl" style="text-align: center;">

                                                    <b>售价:</b>
                                                    <strong>¥<?php echo floatval($rowl['zswprice']); ?></strong>

                                                </p>
                                            </div>
                                        </a></li>
                                <?php } ?>
                            </ul>
                        </div>
                        <div class="clear"></div>

                        <!--分页 -->


                    </div>

                </div>

            </div>


            <? include('footerr.php'); ?>
            <script>
                layui.use(['layedit', 'jquery'], function () {
                    var layedit = layui.layedit
                        , $ = layui.jquery;

                    //构建一个默认的编辑器
                    var index = layedit.build('LAY_demo1');

                    $('.taoreyan').click(function () {
                        var cc = $(this).attr('cc');
                        var c = "@" + cc + " ";
                        var h = $(document).height() - $(window).height();
                        $('html,body').animate({scrollTop: 2 * h}, 500);
                        layedit.setContent(index, c);
                    })

                    $('#LikBasket').click(function () {
                        var tgid = $('#tgid').val();
                        var goodsnum = $('#goodsnum').val();
                        var dirunit = $('#skuid').val();
                        if (typeof(dirunit) == "undefined") {
                            dirunit = 0;
                        }
                        $.ajax({
                            url: 'taocartadd.php',
                            type: 'POST',
                            dataType: 'json',
                            data: {tgid: tgid, goodsnum: goodsnum, dirunit: dirunit},
                        })
                            .done(function (respon) {
                                if (respon.error == 0) {
                                    location.href = "mycollcart.php";
                                } else if (respon.error == 1) {
                                    alert(respon.msg);
                                    location.href = "login.php";
                                } else if (respon.error == 2) {
                                    alert(respon.msg);
                                    location.href = "9999.php";
                                }
                            })
                    })

                });
            </script>

            <script type="text/javascript">

                $('#cc1').on('click', function () {
                    layer.open({
                        type: 1,
                        skin: 'layui-layer-rim', //加上边框
                        area: ['300px', '200px'], //宽高
                        content: '<p style="font-size:20px;margin-top:30px;margin-left:50px;">Tel:0510-82859288</p>'
                    });
                })

                $('#morecc').on('click', function () {
                    var content = ''
                    <?if ($ggunit != 0) { ?>
                    content = '<p style="margin-top:10px;margin-left:10px;color: red">优惠券抵扣金额设定：</p>' +
                        '<p style="margin-top:10px;margin-left:10px;"><img style="height: 20px;width: 60px;" src="./images/hotlevel3.png">类产品，单笔订单满299元可抵扣25元优惠券；单笔订单满199元可抵扣10元优惠券；</p>' +
                        '<br><p style="margin-left:10px;"><img style="height: 20px;width: 40px;" src="./images/hotlevel2.png">类产品，单笔订单满189元可抵扣20元优惠券；</p>' +
                        '<br /><p style="margin-left:10px;"><img style="height: 20px;width: 20px;" src="./images/hotlevel.png">类产品，单笔订单满89元可抵扣3元优惠券；单笔订单满65元可抵扣2元优惠券；</p>' +
                        '<br><p style="margin-left:10px;"><img style="height: 20px;width: 20px;" src="./images/hotlevel.png">+<img style="height: 20px;width: 40px;" src="./images/hotlevel2.png">类产品，单笔订单满159元可抵扣10元优惠券；</p>' +
                        '<br><p style="margin-left:10px;"><img style="height: 20px;width: 20px;" src="./images/hotlevel.png">+<img style="height: 20px;width: 60px;" src="./images/hotlevel3.png">类产品，单笔订单满259元可抵扣10元优惠券；</p>' +
                        '<br><p style="margin-left:10px;"><img style="height: 20px;width: 40px;" src="./images/hotlevel2.png">+<img style="height: 20px;width: 60px;" src="./images/hotlevel3.png">类产品，单笔订单满288元可抵扣25元优惠券；</p>' +
                        '<br><p style="margin-left:10px;"><img style="height: 20px;width: 20px;" src="./images/hotlevel.png">+<img style="height: 20px;width: 40px;" src="./images/hotlevel2.png">+<img style="height: 20px;width: 60px;" src="./images/hotlevel3.png">类产品，单笔订单满358元可抵扣25元优惠券；</p>'

                    <? }else{?>
                    content = '<p style="margin-top:10px;margin-left:10px;">正品保证</p><p style="margin-left:10px;">自营区所售商品100%为正品</p><br /><p style="margin-left:10px;">发货&售后</p><p style="margin-left:10px;">由众晒网提供售后服务</p><br /><p style="margin-left:10px;">关于快递</p><p style="margin-left:10px;">红酒由顺丰快递配送</p><p style="margin-left:10px;">其他海购商品由申通快递配送</p><br /><p style="margin-left:10px;">关于运费</p><p style="margin-left:10px;">红酒顺丰包邮</p><p style="margin-left:10px;">除红酒外的所有商品，实付金额满198元（2公斤内），即可包邮</p>';
                    <? } ?>
                    layer.open({
                        type: 1,
                        skin: 'layui-layer-rim', //加上边框
                        area: ['700px', '350px'], //宽高
                        content: content
                    });
                })

                $('#contseller').on('click', function () {

                    layer.open({
                        type: 1,
                        skin: 'layui-layer-rim', //加上边框
                        area: ['520px', '400px'], //宽高
                        content: '<p style="margin-top:10px;margin-left:10px;">正品保证</p><p style="margin-left:10px;">自营区所售商品100%为正品</p><br /><p style="margin-left:10px;">发货&售后</p><p style="margin-left:10px;">由众晒网提供售后服务</p><br /><p style="margin-left:10px;">关于快递</p><p style="margin-left:10px;">红酒由顺丰快递配送</p><p style="margin-left:10px;">其他海购商品由申通快递配送</p><br /><p style="margin-left:10px;">关于运费</p><p style="margin-left:10px;">红酒顺丰包邮</p><p style="margin-left:10px;">除红酒外的所有商品，实付金额满198元（2公斤内），即可包邮</p>'
                    });
                })
            </script>

            <script>
                function goto_buy() {
                    var goodsnum = $('#goodsnum').val();
                    var dirunit = $('.dirunit').val();
                    // sku信息
                    var skuid = $('#skuid').val();
                    var link = "taopay.php?id=<?php echo $id; ?>" + "&goodsnum=" + goodsnum + "&skuid=" + skuid;
                    window.location.href = link;
                }
            </script>
</body>

</html>
